package com.bw.home.ui

import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import com.bw.home.R
import com.bw.home.databinding.FragmentHomeDetailDescriptionBinding
import com.bw.home.model.entity.SimpleVideoEntity
import com.bw.imageloader.ImageLoaderManager
import com.bw.mvicore.ui.BaseFragment

/**
 * @author:created by hahajing
 * 时间：2024/4/29 0029
 * 企鹅号:444511958
 * 描述:
 */
class HomeDetailDescriptionFragment:BaseFragment() {
    private lateinit var binding: FragmentHomeDetailDescriptionBinding
    private lateinit var simpleVideoEntity: SimpleVideoEntity
    override fun initEvent() {
        binding.tvHomeDetailDescriptionAgree.setOnClickListener {
            val scaleAnim = AnimationUtils.loadAnimation(context,R.anim.anim_scale_icon)
            binding.tvHomeDetailDescriptionAgree.startAnimation(scaleAnim)
            scaleAnim.setAnimationListener(object :Animation.AnimationListener{
                override fun onAnimationStart(animation: Animation?) {}
                override fun onAnimationEnd(animation: Animation?) {
                    binding.tvHomeDetailDescriptionAgree.text=1001.toString()
                    binding.tvHomeDetailDescriptionAgree.setTextColor(Color.RED)
                }
                override fun onAnimationRepeat(animation: Animation?) {}
            })
        }
    }

    override fun initView() {
        super.initView()
        simpleVideoEntity = arguments?.getParcelable<SimpleVideoEntity>("entity")!!
        binding.tvHomeDetailDescriptionTitle.text=simpleVideoEntity.title

        ImageLoaderManager.getInstance().loadFileIntoImageView(context,simpleVideoEntity.avatar_url,binding.ivHomeDetailDescriptionAuthorimg,null)
        binding.tvHomeDetailDescriptionAuthor.text = simpleVideoEntity.name

        getBaseActivity().replaceFragment(R.id.fl_home_detail_Recommend,RecommendFragment())
    }

    override fun generateFragmentRootView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding=FragmentHomeDetailDescriptionBinding.inflate(inflater,container,false)
        return binding.root
    }

    override fun lazyLoad() {

    }
}